
window.MK = {
    
    invokeServer: function( url, type, data, successCallBack, errorCallBack, async) {
        var json = {};
        json.url = url;
        json.method = type;
        json.data=data;
        
        var x_auth_token_key = 'x-auth-token';
        var x_auth_token_value = '';
        
        if (document.cookie.length>0){
            c_start=document.cookie.indexOf(x_auth_token_key + "=")
            if (c_start!=-1){ 
                c_start=c_start + x_auth_token_key.length+1 
                c_end=document.cookie.indexOf(";",c_start)
                if (c_end==-1) c_end=document.cookie.length
                x_auth_token_value =  unescape(document.cookie.substring(c_start,c_end))
            }
        }
        
        if(!x_auth_token_value){
            //window.location.href= "/gams-login";
        }
        
        $.ajax({
            type: 'post',
            url: "/MK",
            data: JSON.stringify(json),
            async:async||false,
            success: function invokeServerSuccess(data) {
            	successCallBack(data);
            },
            error: function invokeServerError(data) {
                if( 401 === data.status){
                    //window.location.href= "/gams-login";
                }else{
                	errorCallBack(data);
                }
            }
        });
    }


    
}